package com.sayimo.maker.mall.goods.service.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sayimo.framework.common.AbstractBaseService;
import com.sayimo.framework.exception.DaoException;
import com.sayimo.framework.exception.ServiceException;
import com.sayimo.maker.mall.goods.dao.GoodsNormsStockInterfaceDao;
import com.sayimo.maker.mall.goods.service.GoodsNormsStockInterfaceService;
import com.sayimo.maker.mall.goods.vo.GoodsNormsStock;


/**
 * @Copyright (C)  广东省尚一互联网有限公司
 * @Project: schoolmallapi
 * @ClassName: GoodsNormsStockInterfaceImplService
 * @Description: 
 * @author:	wangyang
 * @date:	日期：2016年7月15日  时间：下午4:37:33
 * @version 2.0.0
 */
@Service(value = "goodsNormsStockInterfaceService")
public class GoodsNormsStockInterfaceImplService extends AbstractBaseService implements GoodsNormsStockInterfaceService{

	private static Log logger = LogFactory.getLog(GoodsNormsStockInterfaceImplService.class);

	
	@Autowired
	private GoodsNormsStockInterfaceDao goodsNormsStockDao;
	/** 
	* @Title: selectGoodsNormsStock 
	* @Description: 查询
	* @param stockId
	* @return
	* @return GoodsNormsStock
	* @throws 
	*/ 
	@Override
	public GoodsNormsStock selectGoodsNormsStock(Integer stockId)
			throws ServiceException {
		GoodsNormsStock goodsNormsStock=new GoodsNormsStock();
		try {
			goodsNormsStock=goodsNormsStockDao.selectGoodsNormsStock(stockId);
		} catch (DaoException e) {
			logger.debug(e);
			throw new ServiceException(e.getMessage());
		}
		
		return goodsNormsStock;
	}

	/** 
	* @Title: updateGoodsNormsStock 
	* @Description: 修改库存
	* @param goodsNormsStock
	* @return void
	* @throws 
	*/
	@Override
	public int updateGoodsNormsStock(GoodsNormsStock goodsNormsStock)
			throws ServiceException {
		try {
			return goodsNormsStockDao.updateGoodsNormsStock(goodsNormsStock);
		} catch (DaoException e) {
			logger.debug(e);
			throw new ServiceException(e.getMessage());
		}
		
	}

	/** 
	* @Title: updateReturnGroupBuyNumById 
	* @Description: 取消返还团购活动商品数量根据订单id
	* @param id
	* @return Integer
	* @throws 
	*/ 
	@Override
	public Integer updateReturnGroupBuyNumById(Integer orderId)
			throws ServiceException {
		try {
			return goodsNormsStockDao.updateReturnGroupBuyNumById(orderId);
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
	}

}
